
package system.base;

import framework.core.*;

/*
	Author    :Wing
	CreateTime:2008-02-20 17:49:49
*/
public class InSubHisSearchEvent extends SearchEvent
{

	private String m_id = "" ; // all

	private String m_in_bill_id = "" ; // all

	private String m_position_code = "" ; // all

	private String m_position_name = "" ; // all

	private String m_product_id = "" ; // all

	private String m_product_code = "" ; // all

	private String m_product_name = "" ; // all

	private double m_product_price = Value.NULL_DOUBLE ; // all

	private double m_product_count = Value.NULL_DOUBLE ; // all

	private double m_product_money = Value.NULL_DOUBLE ; // all

	private String m_keeper_staff_id = "" ; // all

	private String m_keeper_staff_code = "" ; // all

	private String m_keeper_staff_name = "" ; // all

	private String m_balance_mode = "" ; // all

	private double m_out_product_count = Value.NULL_DOUBLE ; // all

	private String m_status = "" ; // all

	private String m_create_user_id = "" ; // all

	private String m_create_user = "" ; // all

	private String m_create_time = "" ; // all

	private String m_last_update_user_id = "" ; // all

	private String m_last_update_user = "" ; // all

	private String m_last_update_time = "" ; // all

	private String m_is_sync = "" ; // all
	
	private String m_category_code = "" ;
		

public InSubHisSearchEvent() 
{
	super();
	
	setOrderField(InSub.ID);
		
}



	public String getId()
	{
		return m_id ;
	}
	public void setId(String v)
	{
		m_id = v;
	}

	public String getInBillId()
	{
		return m_in_bill_id ;
	}
	public void setInBillId(String v)
	{
		m_in_bill_id = v;
	}

	public String getPositionCode()
	{
		return m_position_code ;
	}
	public void setPositionCode(String v)
	{
		m_position_code = v;
	}
    public String getCategoryCode()
    {
        return m_category_code ;
    }
    public void setCategoryCode(String v)
    {
        m_category_code = v;
    }
	public String getPositionName()
	{
		return m_position_name ;
	}
	public void setPositionName(String v)
	{
		m_position_name = v;
	}

	public String getProductId()
	{
		return m_product_id ;
	}
	public void setProductId(String v)
	{
		m_product_id = v;
	}

	public String getProductCode()
	{
		return m_product_code ;
	}
	public void setProductCode(String v)
	{
		m_product_code = v;
	}

	public String getProductName()
	{
		return m_product_name ;
	}
	public void setProductName(String v)
	{
		m_product_name = v;
	}

	public double getProductPrice()
	{
		return m_product_price ;
	}
	public void setProductPrice(double v)
	{
		m_product_price = v;
	}

	public double getProductCount()
	{
		return m_product_count ;
	}
	public void setProductCount(double v)
	{
		m_product_count = v;
	}

	public double getProductMoney()
	{
		return m_product_money ;
	}
	public void setProductMoney(double v)
	{
		m_product_money = v;
	}

	public String getKeeperStaffId()
	{
		return m_keeper_staff_id ;
	}
	public void setKeeperStaffId(String v)
	{
		m_keeper_staff_id = v;
	}

	public String getKeeperStaffCode()
	{
		return m_keeper_staff_code ;
	}
	public void setKeeperStaffCode(String v)
	{
		m_keeper_staff_code = v;
	}

	public String getKeeperStaffName()
	{
		return m_keeper_staff_name ;
	}
	public void setKeeperStaffName(String v)
	{
		m_keeper_staff_name = v;
	}

	public String getBalanceMode()
	{
		return m_balance_mode ;
	}
	public void setBalanceMode(String v)
	{
		m_balance_mode = v;
	}

	public double getOutProductCount()
	{
		return m_out_product_count ;
	}
	public void setOutProductCount(double v)
	{
		m_out_product_count = v;
	}

	public String getStatus()
	{
		return m_status ;
	}
	public void setStatus(String v)
	{
		m_status = v;
	}

	public String getCreateUserId()
	{
		return m_create_user_id ;
	}
	public void setCreateUserId(String v)
	{
		m_create_user_id = v;
	}

	public String getCreateUser()
	{
		return m_create_user ;
	}
	public void setCreateUser(String v)
	{
		m_create_user = v;
	}

	public String getCreateTime()
	{
		return m_create_time ;
	}
	public void setCreateTime(String v)
	{
		m_create_time = v;
	}

	public String getLastUpdateUserId()
	{
		return m_last_update_user_id ;
	}
	public void setLastUpdateUserId(String v)
	{
		m_last_update_user_id = v;
	}

	public String getLastUpdateUser()
	{
		return m_last_update_user ;
	}
	public void setLastUpdateUser(String v)
	{
		m_last_update_user = v;
	}

	public String getLastUpdateTime()
	{
		return m_last_update_time ;
	}
	public void setLastUpdateTime(String v)
	{
		m_last_update_time = v;
	}

	public String getIsSync()
	{
		return m_is_sync ;
	}
	public void setIsSync(String v)
	{
		m_is_sync = v;
	}
		



	public String viewId() throws Exception
	{
		return Value.view(getId());
	}

	public String viewInBillId() throws Exception
	{
		return Value.view(getInBillId());
	}

	public String viewPositionCode() throws Exception
	{
		return Value.view(getPositionCode());
	}

	public String viewPositionName() throws Exception
	{
		return Value.view(getPositionName());
	}

	public String viewProductId() throws Exception
	{
		return Value.view(getProductId());
	}

	public String viewProductCode() throws Exception
	{
		return Value.view(getProductCode());
	}

	public String viewProductName() throws Exception
	{
		return Value.view(getProductName());
	}

	public String viewProductPrice() throws Exception
	{
		return Value.view(getProductPrice());
	}

	public String viewProductCount() throws Exception
	{
		return Value.view(getProductCount());
	}

	public String viewProductMoney() throws Exception
	{
		return Value.view(getProductMoney());
	}

	public String viewKeeperStaffId() throws Exception
	{
		return Value.view(getKeeperStaffId());
	}

	public String viewKeeperStaffCode() throws Exception
	{
		return Value.view(getKeeperStaffCode());
	}

	public String viewKeeperStaffName() throws Exception
	{
		return Value.view(getKeeperStaffName());
	}

	public String viewBalanceMode() throws Exception
	{
		return Value.view(getBalanceMode());
	}

	public String viewOutProductCount() throws Exception
	{
		return Value.view(getOutProductCount());
	}

	public String viewStatus() throws Exception
	{
		return Value.view(getStatus());
	}

	public String viewCreateUserId() throws Exception
	{
		return Value.view(getCreateUserId());
	}

	public String viewCreateUser() throws Exception
	{
		return Value.view(getCreateUser());
	}

	public String viewCreateTime() throws Exception
	{
		return Value.view(getCreateTime());
	}

	public String viewLastUpdateUserId() throws Exception
	{
		return Value.view(getLastUpdateUserId());
	}

	public String viewLastUpdateUser() throws Exception
	{
		return Value.view(getLastUpdateUser());
	}

	public String viewLastUpdateTime() throws Exception
	{
		return Value.view(getLastUpdateTime());
	}

	public String viewIsSync() throws Exception
	{
		return Value.view(getIsSync());
	}


	public Conditions toConditions() throws Exception
	{
		Conditions c = super.toConditions();

	c.add(getCondition(InSub.ID,getId()));

	c.add(getCondition(InSub.IN_BILL_ID,getInBillId()));

	c.add(getCondition(InSub.POSITION_CODE,getPositionCode()));

	c.add(getCondition(InSub.POSITION_NAME,getPositionName()));

	c.add(getCondition(InSub.PRODUCT_ID,getProductId()));

	c.add(getCondition(InSub.PRODUCT_CODE,getProductCode()));

	c.add(getCondition(InSub.PRODUCT_NAME,getProductName()));

	c.add(getCondition(InSub.PRODUCT_PRICE,getProductPrice()));

	c.add(getCondition(InSub.PRODUCT_COUNT,getProductCount()));

	c.add(getCondition(InSub.PRODUCT_MONEY,getProductMoney()));

	//c.add(getCondition(InSub.KEEPER_STAFF_ID,getKeeperStaffId()));  //annotated by benny 200806020124

	c.add(getCondition(InSub.KEEPER_STAFF_CODE,getKeeperStaffCode()));

	c.add(getCondition(InSub.KEEPER_STAFF_NAME,getKeeperStaffName()));

	c.add(getCondition(InSub.BALANCE_MODE,getBalanceMode()));

	c.add(getCondition(InSub.OUT_PRODUCT_COUNT,getOutProductCount()));

	c.add(getCondition(InSub.STATUS,getStatus()));

	c.add(getCondition(InSub.CREATE_USER_ID,getCreateUserId()));

	c.add(getCondition(InSub.CREATE_USER,getCreateUser()));

	c.add(getCondition(InSub.CREATE_TIME,getCreateTime()));

	c.add(getCondition(InSub.LAST_UPDATE_USER_ID,getLastUpdateUserId()));

	c.add(getCondition(InSub.LAST_UPDATE_USER,getLastUpdateUser()));

	c.add(getCondition(InSub.LAST_UPDATE_TIME,getLastUpdateTime()));

	c.add(getCondition(InSub.IS_SYNC,getIsSync()));
		
	//add by Sindy start
    
    if (getWarehouseCodes() != null) {
        String warehouse = "";
        
        for(int i=0;i<getWarehouseCodes().length;i++){
            if(i == getWarehouseCodes().length - 1){
                warehouse = warehouse + "warehouse_code = '"+ getWarehouseCodes()[i] +"'";
            }else{
                warehouse = warehouse + "warehouse_code = '"+ getWarehouseCodes()[i] +"' or ";
            }
        }
        c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where "+ warehouse +")") ;
     }
     if (!getKeyWord().equalsIgnoreCase(""))
     {
         String[] keyWord = new String[7];
         keyWord[0] = "%" + getKeyWord() + "%";
         keyWord[1] = "%" + getKeyWord() + "%";
         keyWord[2] = "%" + getKeyWord() + "%";
         keyWord[3] = "%" + getKeyWord() + "%";
         keyWord[4] = "%" + getKeyWord() + "%";
         keyWord[5] = "%" + getKeyWord() + "%";
         keyWord[6] = "%" + getKeyWord() + "%";
         
         c.add(InSub.IN_BILL_ID + " in (select in_bill_id from t_in_sub_his a,t_product b where a.product_code = b.CONCENTRICITY_CODE and (b.NAME like ? or b.CONCENTRICITY_CODE like ? or b.MODEL like ? " +
               "or b.SPEC like ? or b.PRODUCT_BRAND like ? or b.MANUFATURER like ? or b.APPENDER_PROPERTY like ? ))",Conditions.CUSTOM,keyWord); 
     }
     
    if (!getInBillCode().equalsIgnoreCase(""))
     {
         c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where in_bill_code = ?)",Conditions.CUSTOM,getInBillCode());
     }
    if (!getInType().equalsIgnoreCase(""))
    {
        c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where in_type = ?)",Conditions.CUSTOM,getInType());
    }    
    if (!getBalanceFlag().equalsIgnoreCase(""))
    {
        c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where balance_flag = ?)",Conditions.CUSTOM,getBalanceFlag());
    }  
    if (!getSendBillCode().equalsIgnoreCase(""))
    {
        c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where send_bill_code = ?)",Conditions.CUSTOM,getSendBillCode());
    }  
    if (!getProviderName().equalsIgnoreCase(""))
    {
        c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where provider_name = ?)",Conditions.CUSTOM,getProviderName());
    }     
    
     if (!getIsNormal().equalsIgnoreCase(""))
     {
         c.add(InSub.IN_BILL_ID + " in (select in_bill_id from t_in_sub_his a,t_product b where a.product_code = b.CONCENTRICITY_CODE and b.is_normal = ?)",Conditions.CUSTOM,getIsNormal());
     }
     
     if (!getStartInTime().equalsIgnoreCase("")) {
         c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where in_time >= ? )",Conditions.CUSTOM,getStartInTime()+" 00:00:00");
     }
     
     if (!getEndInTime().equalsIgnoreCase("")) {
         c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where in_time <= ? )",Conditions.CUSTOM,getEndInTime()+" 23:59:60");
     }
             
     c.add(InSub.IN_BILL_ID + " in (select id from t_in_head_his where warehouse_code like ? )",Conditions.CUSTOM,getWarehouseCodeUser()+"%");
     //c.add(ProductStorage.WAREHOUSE_CODE,Conditions.LIKE,getWarehouseCodeUser()+"%");
//add by Sindy end

     //add by benny start
     if (!getKeeperStaffId().equalsIgnoreCase("")) {
         c.add(InSub.PRODUCT_ID + " in (select product_id from T_WAREHOUSE_PRODUCT where keeper_staff_id = ? )",Conditions.CUSTOM,getKeeperStaffId());
     }
     //add by benny end
   //分类编码查询
     String categorycode3 = getGrandfatherCategoryCode();
     String categorycode2 = getUpperCategoryCode();
     String categorycode1 = getCategoryCode();
     if (categorycode3== null || categorycode3.equalsIgnoreCase("null") || categorycode3.equalsIgnoreCase("")) 
     {
         categorycode3 = "";
         setGrandfatherCategoryCode(categorycode3);
     }    
     if (categorycode2== null || categorycode2.equalsIgnoreCase("null") || categorycode2.equalsIgnoreCase(""))
     {
         categorycode2 = "";
         setUpperCategoryCode(categorycode2);
     }
     if (categorycode1== null || categorycode1.equalsIgnoreCase("null") || categorycode1.equalsIgnoreCase("")) 
     {
         categorycode1 = "";
         setCategoryCode(categorycode1);
     }
     if (!categorycode1.equals(""))
     {
         c.add(OutSub.PRODUCT_CODE + " in (select distinct a.concentricity_code from t_product a where a.category_code=? )",Conditions.CUSTOM,new String[]{categorycode1});
     }
     else if (!categorycode2.equals(""))
     {
         c.add(OutSub.PRODUCT_CODE + " in (select distinct a.concentricity_code from t_product a  join t_product_category b  on a.category_code = b.code where b.CATEGORY_ID2= ? or b.code=? )",Conditions.CUSTOM,new String[]{categorycode2,categorycode2});
     }
     else if (!categorycode3.equals(""))
     {
    
         c.add(OutSub.PRODUCT_CODE + " in (select distinct a.concentricity_code from t_product a  join t_product_category b  on a.category_code = b.code where  b.CATEGORY_ID1= ? or b.code=? )",Conditions.CUSTOM,new String[]{categorycode3,categorycode3}); 
     } 
		return c ;
	}
    private String m_grandfather_category_code = "";    
    public String getGrandfatherCategoryCode()
    {
        return m_grandfather_category_code ;
    }
    public void setGrandfatherCategoryCode(String v)
    {
        m_grandfather_category_code = v;
    }     
    public String viewGrandfatherCategoryCode() throws Exception
    {
        return Value.view(getGrandfatherCategoryCode());
    }   
    private String m_upper_category_code = "";    
    public String getUpperCategoryCode()
    {
        return m_upper_category_code ;
    }
    public void setUpperCategoryCode(String v)
    {
        m_upper_category_code = v;
    }           
    public String viewUpperCategoryCode() throws Exception
    {
        return Value.view(getUpperCategoryCode());
    }   
// add by Sindy start
    private String []m_warehouse_codes;
    public String []getWarehouseCodes()
    {
        return m_warehouse_codes ;
    }
    public void setWarehouseCodes(String []warehouseCodes)
    {
        m_warehouse_codes = warehouseCodes;
    }
    
    private String[] m_warehouse_tree_codes;
    
    public String[] getWarehouseTreeCodes(){
    	return m_warehouse_tree_codes;
    }
    
    public void setWarehouseTreeCodes(String[] warehouseTreeCodes){
    	m_warehouse_tree_codes = warehouseTreeCodes;
    }
    
    private String m_key_word = "";
    public String getKeyWord()
    {
        return m_key_word;
    }
    public void setKeyWord(String keyWord)
    {
        m_key_word = keyWord;
    }
    public String viewKeyWord() throws Exception
    {
        return Value.view(getKeyWord());
    }
   
    private String m_provider_name = "";
    public String getProviderName()
    {
        return m_provider_name ;
    }
    public void setProviderName(String v)
    {
        m_provider_name = v;
    }
    public String viewProviderName() throws Exception
    {
        return Value.view(getProviderName());
    }    
    
    private String m_is_normal = "";
    public String getIsNormal() {
        return this.m_is_normal;
    }
    public void setIsNormal(String isNormal) {
        this.m_is_normal = isNormal;
    }
    
    private String m_balance_flag = "";
    public String getBalanceFlag()
    {
        return m_balance_flag ;
    }
    public void setBalanceFlag(String v)
    {
        m_balance_flag = v;
    } 
    public String viewBalanceFlag() throws Exception
    {
        return Value.view(getBalanceFlag());
    }
    
    private String m_start_inTime = "";
    public String getStartInTime() {
        return this.m_start_inTime;
    }
    public void setStartInTime(String startInTime) {
        this.m_start_inTime = startInTime;
    }
    
    private String m_end_inTime = "";
    public String getEndInTime() {
        return this.m_end_inTime;
    }
    public void setEndInTime(String endInTime) {
        this.m_end_inTime = endInTime;
    }
  
    private String m_warehouse_code_user = "" ; // all
    public String getWarehouseCodeUser()
    {
        return m_warehouse_code_user ;
    }
    public void setWarehouseCodeUser(String v)
    {
        m_warehouse_code_user = v;
    }
    public String viewWarehouseCodeUser() throws Exception
    {
        return Value.view(getWarehouseCodeUser());
    }
    
    private String m_in_type = "";
    public String getInType()
    {
        return m_in_type ;
    }
    public void setInType(String v)
    {
        m_in_type = v;
    }
    public String viewInType() throws Exception
    {
        return Value.view(getInType());
    }
    
    private String m_send_bill_code = "";
    public String getSendBillCode()
    {
        return m_send_bill_code ;
    }
    public void setSendBillCode(String v)
    {
        m_send_bill_code = v;
    }
    public String viewSendBillCode() throws Exception
    {
        return Value.view(getSendBillCode());
    }
    
    private String m_in_bill_code = "";
    public String getInBillCode()
    {
        return m_in_bill_code ;
    }
    public void setInBillCode(String v)
    {
        m_in_bill_code = v;
    }
    public String viewInBillCode() throws Exception
    {
        return Value.view(getInBillCode());
    }
 // add by Sindy end
	
}
